import { httpApi } from '@app-cad/server';

export async function fetchCamData(
  documentId: string,
  documentVersion: string,
  paramsArr: string[],
) {
  const request = paramsArr.map((params) => {
    return httpApi.getCamData({
      documentUuid: documentId,
      version: documentVersion,
      params,
    });
  });
  const responses = await Promise.all(request);
  const data = responses.map((res) => {
    if (Array.isArray(res.data)) {
      return res.data;
    } else {
      return [];
    }
  });

  return data;
}
